<?php
  #session_set_cookie_params(1200); 
  session_start();     
  error_reporting(E_ERROR);
  header('Content-Type:text/html; charset=utf-8');
  define('ROOT',dirname(__FILE__).'/..');              
  
  require(ROOT.'/smarty/Smarty.class.php');    
  require(ROOT.'/include/mysql.class.php');   
  require(ROOT.'/include/log.class.php');      
  require(ROOT.'/include/date.class.php');      
  require(ROOT.'/include/data.class.php');   
  require(ROOT.'/config_db.php');        
  
  //配置smarty
  $smarty = new Smarty();   
  $smarty->template_dir = ROOT.'/admin/html/';
  $smarty->compile_dir = ROOT.'/cache/';
  $smarty->left_delimiter = '{{';
  $smarty->right_delimiter = '}}';
  
  
  //配置log
  $log = KLogger::instance(ROOT.'/logs', KLogger::DEBUG);  

  //检查数据库是否连接成功
  $db=Mysql::getInstance($mysql_host,$mysql_user,$mysql_pass,$mysql_dbname,$mysql_port);
  
  //记录访问痕迹
  $visitorUser = empty($_SESSION['user']['id']) ? '0' : $_SESSION['user']['id'];
  $visitorIP = $_SERVER['REMOTE_ADDR'];
  $visitorURL = 'http://'.$_SERVER ['HTTP_HOST'].$_SERVER['PHP_SELF'];
  $visitorTime = DateUtil::get_YY_mm_dd_HH_mm_ss();
  $sql = "insert into talking_visitor(VisitorUser,VisitorIP,VisitorURL,VisitorTime) values ('$visitorUser','$visitorIP','$visitorURL','$visitorTime')";
  $db->execute($sql);
?>